<?php
include_once(PATH_SQL . 'transaction_sql.php');
include_once(PATH_MODEL . 'transaction_model.php');
include_once(PATH_VIEW_ADMIN . 'transaction_view.php');
include_once(PATH_INCLUDE."constant.php");

$oModelTranSactions = new Model_TranSactions();
$oViewTranSactions = new View_Admin_TranSactions($oModelTranSactions);
$sAction=$_REQUEST['sAction'];
$oUpload = new Upload($_FILES);
switch($sAction) {
    case"do_delete":
    	$oModelTranSactions->deletePacketById($_REQUEST[id]);
    	redir('?sMod=packet_index');
    	break;
    case"edit_form":
    	$oViewTranSactions->editPacketForm($oModelTranSactions);
    	break;
    case"do_edit":
    	$date_time = date("Y-m-d H:i:s");
        $oModelTranSactions->updateTransactionsById($date_time,$_REQUEST[status],$_REQUEST[id]);
        switch($_REQUEST[status]){
        	case TRANS_SUCCESS :
	        	$oModelUserAccount = new Model_TranSactions();
	        	$arr_trans = $oModelUserAccount->insertUserAccount($_REQUEST[user_id]);
        		break;
        	case TRANS_PENDING:
        	case TRANS_REJECT:
        		$oModelUserAccount = new Model_TranSactions();
	        	$arr_trans = $oModelUserAccount->updateUserAccountReject($_REQUEST[user_id]);
        		break;
        }
        echo $date_time;die();
//    	redir('?sMod=packet_index');
    default:
		$oViewTranSactions->displayTransactionsIndex($oModelTranSactions);
		break;
}

$oViewTranSactions->displayPage($oModelTranSactions);
